/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package day05.qlsv;

import day05.sinhvien.BangDiem;
import day05.sinhvien.SinhVien;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class QLSV {

    private static final int SLSV = 3;
    private SinhVien[] listOfSV;
    private int nam;

    public QLSV(int nam) {
        this.nam = nam;
        this.listOfSV = new SinhVien[SLSV];
    }

    /*
     * Nhap sinh vien
     */
    public void nhapDSSV() {
        Scanner s = new Scanner(System.in);
        for (int i = 0; i < this.listOfSV.length; i++) {

            System.out.println("Ten Sinh Vien:");
            String ten = s.next();
            System.out.println("MSSV:");
            String mssv = s.next();
            System.out.println("Tuoi:");
            int tuoi = s.nextInt();
            System.out.println("Diem toan:");
            int toan = s.nextInt();
            System.out.println("Diem ly:");
            int ly = s.nextInt();
            System.out.println("Diem hoa:");
            int hoa = s.nextInt();
            BangDiem svDiem = new BangDiem(toan, ly, hoa);
            SinhVien sv = new SinhVien(ten, mssv, tuoi, svDiem);
            this.listOfSV[i] = sv;
        }


    }
    /*
     * Xuat sinh vien dau
     */

    public void xuatSVDau() {
        for (SinhVien s : this.listOfSV) {
            if (s.ktDauRot()) {
                System.out.println(s);
            }
        }


    }
    /*
     * Lay ra danh sach sinh vien dau
     */

    public SinhVien[] layDSSVDau() {
        SinhVien[] dsSVDau = new SinhVien[this.demSLSVDau()];
        int index = 0;
        for (SinhVien sv : this.listOfSV) {
            if (sv.ktDauRot()) {
                dsSVDau[index] = sv;
                index++;
            }
        }
        return dsSVDau;

    }

    /*
     * dem so luong sv dau
     */
    public int demSLSVDau() {
        int count = 0;
        for (SinhVien s : this.listOfSV) {
            if (s.ktDauRot()) {
                count++;
            }
        }
        return count;
    }
}
